import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 * @author vivi
 * @description
 * @date 2024/4/26
 */

// 倒置字符串
public class demo3 {
    public static void Reverse (char[] s, int left, int right){
        while(left < right){
            char ch = s[left];
            s[left] = s[right];
            s[right] = ch;
            left++;
            right--;
        }
    }
    public static void reverseWord(char[] s, int n){
        int left = 0;
       while(left < n)
        {
            int right = left;
            while(right < n && s[right] != ' ') {
                right++; // 找单词
            }

            // 逆置单个单词
            Reverse(s, left, right - 1);

            while(right < n && s[right] == ' ') {
                right++; // 跳过空格
            }

            left = right;
        }
    }

    public static void main (String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new
                InputStreamReader(System.in));
        char[] s = br.readLine().toCharArray();
        int n = s.length;
        //逆置数组中每个字符
        Reverse(s, 0, n - 1);

        //将单词中字母逆置
        reverseWord(s, n);

        for(char ch : s) {
            System.out.print(ch);
        }
    }
}
